#include <bits/stdc++.h>
#define rg register
#define pc putchar
#define gc getchar
#define pf printf
#define space pc(' ')
#define enter pc('\n')
#define me(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define FOR(i,k,t,p) for(rg int i(k) ; i <= t ; i += p)
#define ROF(i,k,t,p) for(rg int i(k) ; i >= t ; i -= p)
using namespace std ;
bool s_gnd ;
inline void read(){}
template<typename T,typename ...T_>
inline void read(T &x,T_&...p)
{
    x = 0 ;rg int f(0) ; rg char c(gc()) ;
    while(!isdigit(c)) f |= (c=='-'),c = gc() ;
    while(isdigit(c)) x = (x<<1)+(x<<3)+(c^48),c = gc() ;
    x = (f?-x:x) ;
    read(p...);
}
int stk[30],tp ;
inline void print(){}
template<typename T,typename ...T_>
inline void print(T x,T_...p)
{
    if(x < 0) pc('-'),x = -x ;
    do stk[++tp] = x%10,x /= 10 ; while(x) ;
    while(tp) pc(stk[tp--]^48) ; space ;
    print(p...) ;
}
bool S_GND ;
const int N = 2e3+5 ;
int X1,Y1,X2,Y2,n,m,q,top ;
char s[N][N] ;
int vis[N][N] ;
int col[N][N],fa[N],fx[10][10] = {{0,1},{1,0},{0,-1},{-1,0}} ;
void Dfs(int x,int y)
{
    vis[x][y] = 1 ;
    FOR(k,0,3,1)
    {
        int X = x+fx[k][0],Y = y+fx[k][1] ;
        if(X < X1 || X > X2 || Y < Y1 || Y > Y2 || vis[X][Y] || s[X][Y] != '1') continue ;
        Dfs(X,Y) ;
    }
}
signed main()
{
//cerr<<(double)(&s_gnd-&S_GND)/1024.0/1024.0 ;
	freopen("unicom.in","r",stdin) ;
	freopen("unicom.out","w",stdout) ;
    read(n,m,q) ;
    FOR(i,1,n,1) scanf("%s",s[i]+1) ;
    while(q--)
    {
        int res = 0 ; read(X1,Y1,X2,Y2) ;
        FOR(i,X1,X2,1) FOR(j,Y1,Y2,1) if(!vis[i][j] && s[i][j] == '1') ++res,Dfs(i,j) ;
        FOR(i,X1,X2,1) FOR(j,Y1,Y2,1) vis[i][j] = 0 ;
        print(res),enter ;
    }
    return 0 ;
}